package sg.nus.iss.vmcs.gui;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Dialog;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Message Dialog used to display messages<br><br>
 * Modifications:
 * <li>Updated dialog to remove redundant codes</li>
 * <br>
 * <br>
 * @author Pang Pingli
 * @author Philip Chew
 */
public class MessageDialog extends Dialog implements ActionListener {
	
	/** Generated Serial ID */
	private static final long serialVersionUID = 9087033691214772916L;
	
	//Generic Messages commonly used
	public final static String  LOCK_DOOR = "Please Lock the Door before You Leave !!!";
	public final static String  NUMBER_FORMAT_ERROR = "You must enter digits only!!";

	/**
	 * Constructor for message dialog. Initializes UI components
	 * @param fr Dialog that this dialog belongs to
	 * @param msg Message to be displayed
	 */
	public MessageDialog(Dialog fr, String msg) {
		super (fr, "Message", true);
		this.setLayout(new BorderLayout());
		
	    Label   lblDisplay = new Label (msg);
	    this.add("Center", lblDisplay);
	      
	    Button  btnOkay = new Button ("OK");
	    btnOkay.addActionListener(this);
	    this.add("South", btnOkay);

	    pack();
	    setLocation(200, 100);
	    this.setVisible(true);
	}

	/**
	 * Action Perform override, disposes dialog upon button action
	 */
    public void actionPerformed(ActionEvent e) {
    	this.dispose();
    }
}